package com.my.goodsmanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.my.goodsmanage.dao.GoodsMapper;
import com.my.goodsmanage.dao.UserMapper;
import com.my.goodsmanage.entity.Goods;
import com.my.goodsmanage.entity.User;
import com.my.goodsmanage.service.GoodsService;
import com.my.goodsmanage.service.UserService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 徐佳辉
 * @date 2020/8/6 15:12
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Override
    public void pageListCondition(Page<Goods> goodsPage, int userId, String name) {
        if (userId < 0) {
            baseMapper.selectPage(goodsPage, null);
            return;
        }
        QueryWrapper<Goods> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        if (StringUtils.isEmpty(name)) {
            baseMapper.selectPage(goodsPage, wrapper);
        }else {
            wrapper.like("good_name",name);
            baseMapper.selectPage(goodsPage, wrapper);
        }


        return;
    }
}
